package com.FindMyStuff.Testing;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import org.junit.Test;

import com.FindMyStuff.Model.InputChecker;
import com.FindMyStuff.Model.ItemCategory;
import com.FindMyStuff.Model.ItemType;
import com.FindMyStuff.Model.UserStatus;

public class M10Test {
	/**
	 * Test the output of CheckEmail based on the input
	 */
	@Test
	public void CheckEmailTesting() {
		assertTrue(InputChecker.checkEmail("admin"));
		assertFalse(InputChecker.checkEmail("@.com"));
		assertFalse(InputChecker.checkEmail("@a.com"));
		assertTrue(InputChecker.checkEmail("a@a.com"));
		assertFalse(InputChecker.checkEmail(null));
	}
	
	/**
	 * Test the output of CheckReward based on the input
	 */
	@Test
	public void CheckRewardTesting() {
		assertFalse(InputChecker.checkReward(""));
		assertFalse(InputChecker.checkReward("a"));
		assertFalse(InputChecker.checkReward("a.a"));
		assertFalse(InputChecker.checkReward("a."));
		assertTrue(InputChecker.checkReward(".0"));
		assertTrue(InputChecker.checkReward("1."));
		assertTrue(InputChecker.checkReward("1.0"));
		assertFalse(InputChecker.checkReward("."));
		assertFalse(InputChecker.checkEmail(null));
	}
	
	/**
	 * Test the output of SimpleCheckOnInputs based on the input
	 */
	@Test
	public void SimpleCheckOnInputsTesting() {
		assertTrue(InputChecker.simpleCheckOnInputs("", ItemType.Lost, "", "", "").equals("Please Fill Out All of the Fields"));
		assertTrue(InputChecker.simpleCheckOnInputs("5", ItemType.Lost, "a", "a", "a").equals(""));
		assertTrue(InputChecker.simpleCheckOnInputs("", ItemType.Found, "a", "a", "a").equals(""));
		assertTrue(InputChecker.simpleCheckOnInputs("", ItemType.Found, "a", "", "").equals("Please Fill Out All of the Fields"));
		assertTrue(InputChecker.simpleCheckOnInputs("", ItemType.Found, "", "a", "").equals("Please Fill Out All of the Fields"));
		assertTrue(InputChecker.simpleCheckOnInputs("", ItemType.Found, "", "", "a").equals("Please Fill Out All of the Fields"));
		assertTrue(InputChecker.simpleCheckOnInputs(null, ItemType.Found, "", "", "a").equals("Please Fill Out All of the Fields"));
		assertTrue(InputChecker.simpleCheckOnInputs("", null, "", "", "a").equals("Please Fill Out All of the Fields"));
		assertTrue(InputChecker.simpleCheckOnInputs("", ItemType.Found, null, "", "a").equals("Please Fill Out All of the Fields"));
		assertTrue(InputChecker.simpleCheckOnInputs("", ItemType.Found, "", null, "a").equals("Please Fill Out All of the Fields"));
		assertTrue(InputChecker.simpleCheckOnInputs("", ItemType.Found, "", "", "null").equals("Please Fill Out All of the Fields"));
	}
	
	/**
	 * Test the output of RemoveQuotesTesting based on the input
	 */
	@Test
	public void RemoveQuotesTesting() {
		assertTrue(InputChecker.removeQuotes(null).equals(""));
		assertTrue(InputChecker.removeQuotes("").equals(""));
		assertTrue(InputChecker.removeQuotes("\"").equals(""));
		assertTrue(InputChecker.removeQuotes("\"\"").equals(""));
		assertTrue(InputChecker.removeQuotes("Something\"").equals("Something"));
		assertTrue(InputChecker.removeQuotes("\"Something\"").equals("Something"));
	}
	
	@Test
	public void CheckPasswordTesting() {
		assertTrue(InputChecker.checkPassword("qwerty", "notthesame").equals("Passwords do not match.\n")); //password matching
		assertTrue(InputChecker.checkPassword("asdf", "asdf").equals("Password should be between 5 and 13 characters.\n")); //password too short
		assertTrue(InputChecker.checkPassword("thisiswaytoolong", "thisiswaytoolong").equals("Password should be between 5 and 13 characters.\n")); //password too long
		assertTrue(InputChecker.checkPassword("!@#$%&", "!@#$%&").equals("Password should only be made of letters and numbers.\n"));
		assertTrue(InputChecker.checkPassword("Validpass1", "Validpass1").equals("")); //correct password
	}
	
	/**
	 * Test the return value(converted enum) of convertToStatus based on the string
	 */
	@Test
	public void CheckConvertToStatusTesting(){
		assertTrue(UserStatus.convertToStatus("u").equals(UserStatus.Unlocked));
		assertTrue(UserStatus.convertToStatus("l").equals(UserStatus.Locked));
		assertFalse(UserStatus.convertToStatus("u").equals(UserStatus.Locked));
		assertFalse(UserStatus.convertToStatus("l").equals(UserStatus.Unlocked));
		
	}
	
	/**
	 * Test the return value(converted enum) of convertToCategory based on the string
	 */
	@Test
	public void CheckConvertToCategoryTesting(){
		assertTrue(ItemCategory.convertToCategory("h").equals(ItemCategory.Heirloom));
		assertTrue(ItemCategory.convertToCategory("k").equals(ItemCategory.Keepsake));
		assertTrue(ItemCategory.convertToCategory("o").equals(ItemCategory.Other));
		assertTrue(ItemCategory.convertToCategory("a").equals(ItemCategory.All));
		assertFalse(ItemCategory.convertToCategory("i").equals(ItemCategory.Heirloom));
	}
	
	
}

